import request from "@/router/axios";

export const getList = (current, size, params) => {
  return request({
    url: "/api/blade-system/dict/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
    },
  });
};

export const getParentList = (page, limit, params) => {
  return request({
    url: "/api/backstage/dictionary/index",
    method: "get",
    params: {
      ...params,
      page,
      limit,
    },
  });
};

export const getChildList = (current, size, pid, params) => {
  return request({
    url: "/api/backstage/dictionary/index",
    method: "get",
    params: {
      ...params,
      current,
      size,
      pid: pid,
    },
  });
};

export const remove = (id) => {
  return request({
    url: "/api/backstage/dictionary/delete",
    method: "post",
    data: {
      id,
    },
  });
};

export const add = (row) => {
  return request({
    url: "/api/backstage/dictionary/createUpdate",
    method: "post",
    data: row,
  });
};

export const update = (row) => {
  return request({
    url: "/api/backstage/dictionary/createUpdate",
    method: "post",
    data: row,
  });
};

export const getDict = (id) => {
  return request({
    url: "/api//dictionary/createUpdate",
    method: "get",
    params: {
      id,
    },
  });
};
export const getDictTree = () => {
  return request({
    url: "/api/blade-system/dict/tree?code=DICT",
    method: "get",
  });
};

export const getDictionary = (params) => {
  return request({
    url: "/api/blade-system/dict/dictionary",
    method: "get",
    params,
  });
};
